import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'

//axios测试
import test from '../views/test.vue'

// client 端
import Client from '../views/Client.vue'
import WelcomeClient from '../components/client/Welcome.vue'
import Personalcentrecl from '../components/client/worktable/Personalcentrecl.vue'
import Ordercl from '../components/client/order/Ordercl.vue'
import Inquirycl from '../components/client/order/Inquirycl.vue'
import Trackingcl from '../components/client/transport/Trackingcl.vue'
import Orderformcl from '../components/client/transport/Orderform.vue'
import Contractcl from '../components/client/contract/Contract.vue'
import Receiptcl from '../components/client/receipt/Receipt.vue'
import Settlementcl from '../components/client/settlement/Settlement.vue'
import SettlementclXq from '../components/client/settlement/SettlementXq.vue'
// import Invoicecl from '../components/client/invoice/Invoice.vue'
import ContractManagement from "@/components/client/invoice/ContractManagement";
import Detail from "@/components/client/invoice/Detail";
import KaiPiao from "@/components/client/invoice/KaiPiao";
import Systemcl from '../components/client/system/System.vue'
import CreateMenu from '../components/client/order/CreateMenu.vue'
import checkorder from '../components/client/order/CheckOrder.vue'
import addorder from '../components/client/order/AddOrder.vue'
import corder from '../components/client/order/Coder.vue'
import ReturnConfirm from "@/components/client/receipt/ReturnConfirm";






// carrier 端
import Carrier from '../views/Carrier.vue'
import WelcomeCarrier from '../components/carrier/Welcome.vue'
import Personalcentre from '../components/carrier/worktable/Personalcentre.vue'
import Customermanagement from '../components/carrier/customermanagement/Customermanagement.vue'
import Inquirylist from '../components/carrier/inquirymanagement/Inquirylist.vue'
import Orderlist from '../components/carrier/order/Orderlist.vue'
import Transportplan from '../components/carrier/transportplan/Transportplan.vue'
import Goodssplit from '../components/carrier/transportplan/Goodssplit.vue'
import Linesplit from '../components/carrier/transportplan/Linesplit.vue'
import Distribution from '../components/carrier/scheduling/Distribution.vue'
import Orderdistribution from '../components/carrier/scheduling/Orderdistribution.vue'
import Tracking from '../components/carrier/transportimplementation/Tracking.vue'
import Billoflading from '../components/carrier/transportimplementation/Billoflading.vue'
import Signature from '../components/carrier/returnreceipt/Signature.vue'
import Handover from '../components/carrier/returnreceipt/Handover.vue'
import Receivables from '../components/carrier/settlement/Receivables.vue'
import getShengPi from '../components/carrier/settlement/GetShenPi.vue'
import getJieSuan from '../components/carrier/settlement/GetJieSuan.vue'
import getTiaoJia from '../components/carrier/settlement/GetTiaoJia.vue'
import Accountspayable from '../components/carrier/settlement/Accountspayable.vue'
import SetShengPi from '../components/carrier/settlement/SetShenPi.vue'
import SetJieSuan from '../components/carrier/settlement/SetJieSuan.vue'
import SetTiaoJia from '../components/carrier/settlement/SetTiaoJia.vue'
// import Invoice from '../components/carrier/invoice/Invoice.vue'
import ContractManagement2 from "@/components/carrier/invoice/ContractManagement2";
import Detail2 from "@/components/carrier/invoice/Detail2";
import KaiPiao2 from "@/components/carrier/invoice/KaiPiao2";
import Cars from '../components/carrier/Dynamic/Cars.vue'
import Personnels from '../components/carrier/Dynamic/Personnels.vue'
import KPI from '../components/carrier/Dynamic/KPI.vue'
import Abnormalities from '../components/carrier/abnormalities/Abnormalities.vue'
import Deal from "@/components/carrier/abnormalities/Deal";
import AbsDetail from "@/components/carrier/abnormalities/AbsDetail";
import Basicinformation from '../components/carrier/System/Basicinformation.vue'
import Network from '../components/carrier/System/Network.vue'
import Driveraccount from '../components/carrier/System/Driveraccount.vue'
import Addpersonnel from '../components/carrier/System/Addpersonnel.vue'
import Operationallog from '../components/carrier/System/Operationallog.vue'
import Addmessage from '../components/carrier/System/Addmessage.vue'
import Modificationmessage from '../components/carrier/System/Modificationmessage.vue'
import Auditmessage from '../components/carrier/System/Auditmessage.vue'

// transport 端
import Transport from '../views/Transport.vue'
import Welcometransport from '../components/transport/Welcome.vue'
import Personalcentretr from '../components/transport/worktable/Personalcentre.vue'
import Orderlisttr from '../components/transport/order/Orderlist.vue'
import AddOrder from '../components/transport/order/AddOrder.vue'
import CheckPrice from '../components/transport/order/CheckPrice.vue'
import DDCheck from '../components/transport/order/DDCheck.vue'
import SurePrice from '../components/transport/order/SurePrice.vue'


import Trackingcltr from '../components/transport/transportim/Trackingcl.vue'
import Abnormitytr from '../components/transport/transportim/Abnormity.vue'
import Deliverytr from '../components/transport/transportim/Delivery.vue'
import Signtr from '../components/transport/transportim/Sign.vue'
import UploadDeliverytr from '../components/transport/transportim/UploadDelivery.vue'
import Receipttr from '../components/transport/transportim/Receipt.vue'
import Quotationtr from '../components/transport/quotation/Quotation.vue'
import Routetr from '../components/transport/quotation/Route.vue'
import Settlementtr from '../components/transport/settlement/Settlement.vue'
import Contracttr from '../components/transport/contract/Contract.vue'
import Carstr from '../components/transport/Dynamic/Cars.vue'
import Informationtr from '../components/transport/system/Information.vue'
import Abnormalities2 from "@/components/transport/abnormalities/Abnormalities2";


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login',
    meta:{ requireAuth:false,title:'登录'}
  },
  {
    path: '/login',
    component: Login,
    meta:{ requireAuth:false,title:'登录'}
  },
  {
    path: '/test',
    component: test,
    meta:{ requireAuth:false,title:'测试'}
  },
  {
    path: '/carrier',
    component: Carrier,
    redirect: '/carrier/welcomecarrier',
    children: [
      { path: '/carrier/welcomecarrier', component: WelcomeCarrier, meta:{ requireAuth:true,title:'恭迎龙王！'} },
      { path: '/carrier/personalcentre', component: Personalcentre, meta:{ requireAuth:true,title:'个人中心'}  },
      { path: '/carrier/customermanagement', component: Customermanagement, meta:{ requireAuth:true,title:'客户管理'}},
      { path: '/carrier/inquirymanagement', component: Inquirylist, meta:{ requireAuth:true,title:'询价单总览'}},
      { path: '/carrier/order', component: Orderlist, meta:{ requireAuth:true,title:'订单总览'}},
      { path: '/carrier/transportplan', component: Transportplan, meta:{ requireAuth:true,title:'运输计划'} },
      { path: '/carrier/goodssplit', component: Goodssplit, meta:{ requireAuth:true,title:'货物拆分'} },
      { path: '/carrier/linesplit', component: Linesplit, meta:{ requireAuth:true,title:'线路拆分'} },
      { path: '/carrier/scheduling/distribution', component: Distribution, meta:{ requireAuth:true,title:'调度配载'} },
      { path: '/carrier/scheduling/orderdistribution', component: Orderdistribution, meta:{ requireAuth:true,title:'订单派发'} },
      { path: '/carrier/transportimplementation/tracking', component: Tracking, meta:{ requireAuth:true,title:'在线跟踪'} },
      { path: '/carrier/transportimplementation/billoflading', component: Billoflading, meta:{ requireAuth:true,title:'提货单'} },
      { path: '/carrier/returnreceipt/signature', component: Signature, meta:{ requireAuth:true,title:'签收单'} },
      { path: '/carrier/returnreceipt/handover', component: Handover, meta:{ requireAuth:true,title:'回单交接'} },
      { path: '/carrier/settlement/receivables', component: Receivables, meta:{ requireAuth:true,title:'应收款结算'} },
      { path: '/carrier/settlement/accountspayable', component: Accountspayable, meta:{ requireAuth:true,title:'应付款结算'} },
      { path: '/carrier/settlement/getJieSuan', component: getJieSuan, meta:{ requireAuth:true,title:'应收款结算处理'} },
      { path: '/carrier/settlement/getShengPi', component: getShengPi, meta:{ requireAuth:true,title:'应收款审批处理'} },
      { path: '/carrier/settlement/getTiaoJia', component: getTiaoJia, meta:{ requireAuth:true,title:'应收款调价处理'} },
      { path: '/carrier/settlement/accountspayable', component: Accountspayable, meta:{ requireAuth:true,title:'应付款结算'} },
      { path: '/carrier/settlement/setJieSuan', component: SetJieSuan, meta:{ requireAuth:true,title:'应付款结算处理'} },
      { path: '/carrier/settlement/setShengPi', component: SetShengPi, meta:{ requireAuth:true,title:'应付款审批处理'} },
      { path: '/carrier/settlement/setTiaoJia', component: SetTiaoJia, meta:{ requireAuth:true,title:'应付款调价处理'} },

      { path: '/carrier/contractManagement2', component: ContractManagement2, meta:{ requireAuth:true,title:'发票总览'} },
      { path: '/carrier/detail2', component: Detail2, meta:{ requireAuth:true,title:'查看详情'} },
      { path: '/carrier/kaiPiao2', component: KaiPiao2, meta:{ requireAuth:true,title:'新增发票'} },
      { path: '/carrier/Dynamic/cars', component: Cars, meta:{ requireAuth:true,title:'车辆管理'} },
      { path: '/carrier/Dynamic/personnels', component: Personnels, meta:{ requireAuth:true,title:'人员管理'} },
      { path: '/carrier/Dynamic/kPI', component: KPI, meta:{ requireAuth:true,title:'KPI数据'} },
      { path: '/carrier/abnormalities', component: Abnormalities, meta:{ requireAuth:true,title:'异常统计'} },
      { path: '/carrier/absDetail', component: AbsDetail, meta:{ requireAuth:true,title:'异常查看'} },
      { path: '/carrier/deal', component: Deal, meta:{ requireAuth:true,title:'异常处理'} },
      { path: '/carrier/System/basicinformation', component: Basicinformation, meta:{ requireAuth:true,title:'基础信息'} },
      { path: '/carrier/System/network', component: Network, meta:{ requireAuth:true,title:'网点管理'} },
      { path: '/carrier/System/driveraccount', component: Driveraccount, meta:{ requireAuth:true,title:'司机账号管理'} },
      { path: '/carrier/System/addpersonnel', component: Addpersonnel, meta:{ requireAuth:true,title:'人员管理'} },
      { path: '/carrier/System/operationallog', component: Operationallog, meta:{ requireAuth:true,title:'操作日志'} },
      { path: '/carrier/System/addmessage', component: Addmessage, meta:{ requireAuth:true,title:'新增消息'} },
      { path: '/carrier/System/modificationmessage', component: Modificationmessage, meta:{ requireAuth:true,title:'修改消息'} },
      { path: '/carrier/System/auditmessage', component: Auditmessage, meta:{ requireAuth:true,title:'审核消息'} },


      { path: '/carrier/goodssplit', component: Goodssplit, meta:{ requireAuth:true,title:'审核消息'} },
      { path: '/carrier/linesplit', component: Linesplit, meta:{ requireAuth:true,title:'审核消息'} },

    ]
  },
  {
    path: '/client',
    component: Client,
    redirect: '/client/welcomeclient',
    children: [
      { path: '/client/welcomeclient', component: WelcomeClient, meta:{ requireAuth:true,title:'欢迎光临！'} },
      { path: '/client/personalcentre', component: Personalcentrecl, meta:{ requireAuth:true,title:'个人中心'} },
      { path: '/client/order/order', component: Ordercl, meta:{ requireAuth:true,title:'询价单'} },
      { path: '/client/order/inquiry', component: Inquirycl, meta:{ requireAuth:true,title:'下订单'} },
      { path: '/client/order/CreateMenu', component: CreateMenu, meta:{ requireAuth:true,title:'创建询价单'} },
      { path: '/client/order/checkorder', component: checkorder, meta:{ requireAuth:true,title:'订单'} },
      { path: '/client/order/addorder', component: addorder, meta:{ requireAuth:true,title:'下订单(1)'} },
      { path: '/client/order/corder', component: corder, meta:{ requireAuth:true,title:'下订单(2)'} },


      { path: '/client/tracking', component: Trackingcl, meta:{ requireAuth:true,title:'在途跟踪'} },
      { path: '/client/orderform', component: Orderformcl, meta:{ requireAuth:true,title:'在途跟踪'} },
      { path: '/client/contract', component: Contractcl, meta:{ requireAuth:true,title:'合同管理'} },
      { path: '/client/receipt', component: Receiptcl, meta:{ requireAuth:true,title:'回单管理'} },
      { path: '/client/ReturnConfirm', component: ReturnConfirm, meta:{ requireAuth:true,title:'回单确认'}},
      { path: '/client/settlement', component: Settlementcl, meta:{ requireAuth:true,title:'订单结算'} },
      { path: '/client/SettlementXq', component: SettlementclXq, meta:{ requireAuth:true,title:'结算详情'} },
      { path: '/client/contractManagement', component: ContractManagement, meta:{ requireAuth:true,title:'发票总览'} },
      { path: '/client/detail', component: Detail, meta:{ requireAuth:true,title:'查看详情'} },
      { path: '/client/kaiPiao', component: KaiPiao, meta:{ requireAuth:true,title:'申请发票'} },
      { path: '/client/system', component: Systemcl, meta:{ requireAuth:true,title:'系统设置'} },
    ]
  },
  {
    path: '/transport',
    component: Transport,
    redirect: '/transport/welcometransport',
    children: [
      { path: '/transport/welcometransport', component: Welcometransport, meta:{ requireAuth:true,title:'工人爷爷您好！'} },
      { path: '/transport/personalcentre', component: Personalcentretr, meta:{ requireAuth:true,title:'个人中心'} },
      { path: '/transport/orderlist', component: Orderlisttr, meta:{ requireAuth:true,title:'订单管理'} },
      { path: '/transport/trackingcl', component: Trackingcltr, meta:{ requireAuth:true,title:'在途跟踪'} },
      { path: '/transport/delivery', component: Deliverytr, meta:{ requireAuth:true,title:'提货单'} },
      { path: '/transport/abnormity', component: Abnormitytr, meta:{ requireAuth:true,title:'异常上报'} },
      { path: '/transport/sign', component: Signtr, meta:{ requireAuth:true,title:'签收单'} },
      { path: '/transport/uploadDelivery', component: UploadDeliverytr, meta:{ requireAuth:true,title:'上传提货单'} },
      { path: '/transport/receipt', component: Receipttr, meta:{ requireAuth:true,title:'回单交接'} },
      { path: '/transport/quotation', component: Quotationtr, meta:{ requireAuth:true,title:'待报价订单'} },
      { path: '/transport/route', component: Routetr, meta:{ requireAuth:true,title:'常规路线报价'} },
      { path: '/transport/settlement', component: Settlementtr, meta:{ requireAuth:true,title:'结算统计'} },
      { path: '/transport/contract', component: Contracttr, meta:{ requireAuth:true,title:'合同管理'} },
      { path: '/transport/cars', component: Carstr, meta:{ requireAuth:true,title:'车辆信息'} },
      { path: '/transport/information', component: Informationtr, meta:{ requireAuth:true,title:'资料设置'} },
      { path: '/transport/abnormalities2', component: Abnormalities2,meta:{ requireAuth:true,title:'资料设置'} },

      { path: '/transport/addorder', component: AddOrder,meta:{ requireAuth:true,title:'添加订单'} },
      { path: '/transport/checkprice', component: CheckPrice,meta:{ requireAuth:true,title:'订单审核'} },
      { path: '/transport/ddcheck', component: DDCheck,meta:{ requireAuth:true,title:'订单询价'} },
      { path: '/transport/sureprice', component: SurePrice,meta:{ requireAuth:true,title:'确认报价'} },

    ]
  }
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

//路由实例上的全局路由前置守卫 任何路由跳转都会经由此守卫
//axios的路由请求也会拦截


/* 

router.beforeEach((to,from,next) =>{
  //获取login.vue中 存的sessionStorage. userInfo包含 登录状态 和 登录者名称
  let userInfo = JSON.parse(sessionStorage.getItem('loginInfo'));
    //通过路由元信息 判断是否需要验证
if(to.meta.requireAuth){
    //如要要验证 用userInfo判断是否登录 --如果：userInfo不存在 或 userInfo存在但logined为false。就是没有登录。即在跳转到login界面
    if(!userInfo || userInfo&&!userInfo.logined){
        console.log('没有登录')
        router.push('/login')
    }else{ 
      //登录了就放行
      next()
    }
}else{
    next()
}
    console.log('前置守卫')
})

*/

//路由后置守卫 设置title
router.afterEach((to,from)=>{
  //把页面的url中 的title信息部分 改为和路由元中相同title名
  document.title=to.meta.title
  
})  





export default router
